<?xml version="1.0" encoding="ISO-8859-1" ?>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
	  xmlns:a4j="http://richfaces.org/a4j">

	<f:subview id="subviewPopupServico">
	
		<rich:modalPanel id="popupServico" autosized="true" headerClass="height:20px;" >
		
			<f:facet name="header">
				<h:outputText value="Consultar Servico" />
			</f:facet>
			
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/images/close.gif" styleClass="botao_fechar_popup" id="hideLink">
						<rich:componentControl for="popupServico" attachTo="hideLink" operation="hide" event="onclick" />
					</h:graphicImage>
				</h:panelGroup>
			</f:facet>
			
			<a4j:form ajaxSubmit="true" id="formServicoPopup">
			
				<h:panelGrid columns="3">
				<a4j:commandButton action="#{servicoBackBean.obterListaServico}" value="#{bundle.servico_btn_consultar}" reRender="formServicoPopup" />
				
				<a4j:commandButton value="#{bundle.servico_btn_novo}" actionListener="#{servicoBackBean.listenerIrInserirServico}" id="btnNovo" reRender="formServicoManter">
					<rich:componentControl for="manterServico" attachTo="btnNovo" operation="show" event="onclick" />
				</a4j:commandButton>
				
				<a4j:commandButton value="#{bundle.servico_btn_voltar}" id="btnVoltar" reRender="formServicoPopup" >
                	<rich:componentControl for="popupServico" attachTo="btnVoltar" operation="hide" event="onclick" />
                </a4j:commandButton>
                
				</h:panelGrid>
				
				<div class="linha"/>
			
				
				<rich:dataTable value="#{servicoBackBean.servicoFormBean.listaServico}" var="servico" id="gridServico" rows="10" align="center" width="100%">
				
					<rich:column filterBy="#{servico.codigo}">
						<f:facet name="header">
							<h:outputText value="#{bundle.servico_codigo}"/>
						</f:facet>
						<h:outputText value="#{servico.codigo}"/>
					</rich:column>
					
					<rich:column filterBy="#{servico.descricao}">
						<f:facet name="header">
							<h:outputText value="#{bundle.servico_descricao}"/>
						</f:facet>
						<h:outputText value="#{servico.descricao}"/>
					</rich:column>
					
					<rich:column filterBy="#{servico.categoriaVO.descricao}">
						<f:facet name="header">
							<h:outputText value="#{bundle.servico_categoria}"/>
						</f:facet>
						<h:outputText value="#{servico.categoriaVO.descricao}"/>
					</rich:column>
                    
                    <rich:column filterBy="#{servico.estoqueAtual}">
						<f:facet name="header">
							<h:outputText value="Disponivel"/>
						</f:facet>
						<h:outputText value="#{servico.estoqueAtual}"/>
					</rich:column>
                    
					<rich:column>
						<a4j:commandButton id="btnSelecionar" value="#{bundle.servico_btn_selecionar}" reRender="formServicoPopup"
										   onclick="preencheDadosPopupServico('#{servico.codigo}', '#{servico.descricao}', '#{servico.precoVenda}');">
							<rich:componentControl for="popupServico" attachTo="btnSelecionar" operation="hide" event="onclick" />
						</a4j:commandButton>
					</rich:column>
					
				</rich:dataTable>
	            <rich:datascroller for="gridServico" maxPages="10"/>
				
			</a4j:form>

		</rich:modalPanel>
	</f:subview>
	
	<ui:include src="/pages/servico/manterServico.xhtml" />
	
</html>